<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class VLable extends Model
{
    //
    protected $table = 'v_lable';

    /**
     * @author sql
     * 根据标签名称获取信息
     * $lable_type 1.司机通讯录
     */
    public function getInfoByLableName($lable_name, $lable_type = 1)
    {
        return VLable::where('lable_name', $lable_name)->first();
    }

    /**
     * 创建标签
     * $lable_type 1.司机通讯录标签
     */
    public function add($lable_name, $lable_type = 1)
    {
        $model = new VLable;
        // $model->created_at = date('Y-m-d H:i:s', time());
        // $model->lable_name = $lable_name;
        $data['lable_name'] = $lable_name;
        $data['lable_type'] = $lable_type;
        $data['created_at'] = date('Y-m-d H:i:s', time());
        $model::insert($data);
        return DB::getPdo()->lastInsertId();
    }
}
